/**
 * Created by no1 on 2015/8/6.
 */
"use strict";

//var sequelize = require('../sequelize.js');
var sequelize = require('../sequelize.js');
var Sequelize = require('sequelize');
let DataTypes = Sequelize;

var OrderPayWay = sequelize.define('mh_order_payway', {
    //id
    opy_id: {
      type: DataTypes.INTEGER(20),
      primaryKey: true,
      autoIncrement: true,
      allowNull: false
    },
    //订单id
    order_id: {
      type: DataTypes.INTEGER(10),
      allowNull: false
    },
    //支付方式  1：优惠券 2：微信支付 3：支付宝支付 4:余额支付
    pay_way: {
      type: DataTypes.INTEGER(1),
      allowNull: false,
      defaultValue: 1
    },
    //支付金额
    price: {
      type: DataTypes.DECIMAL(10, 2),
      allowNull: true,
      defaultValue: '0.00'
    },
    //第三方支付返回数据
    return_data: {
      type: DataTypes.STRING,
      allowNull: true,
      defaultValue: ''
    },
    //优惠券编号
    coupon_code: {
      type: DataTypes.STRING,
      allowNull: true,
      defaultValue: ''
    }
  },
  {
    indexes: [
      {
        unique: true,
        fields: ['opy_id']
      }
    ],
    tableName: 'mh_order_payway',
    createdAt: false,
    updatedAt: false
  }
);

module.exports = OrderPayWay;